#!/bin/bash
#
# This script uploads android build to repositories defined in maven-push.gradle
# It also builds and uploads Kotlin docs

set -e

source $(dirname $0)/library
version=$(wc_read_version  $1)

if [[ $(uname -s) == "Darwin" ]]; then
    export BOOST_ROOT=$(brew --prefix boost)
fi

echo "Building $version"

export ANDROID_HOME="$HOME/Library/Android/sdk"
pushd android
./gradlew clean build assembleRelease publish -Pversion="$version"

echo "Android build uploaded"
popd # android

echo "Building docs..."
tools/kotlin-doc

pushd build/dokka

filename=kdoc.zip
echo "Upload asset $filename"
download_url=$(wc_upload_asset ${version} ${filename})
echo "download_url is $download_url"

popd # build/dokka

